home *** CD-ROM | disk | FTP | other *** search
/ Magnum One / Magnum One (Mid-American Digital) (Disc Manufacturing).iso / d12 / cdriver.arc / DRIVER.DOC next >
Text File  |  1986-03-14  |  5KB  |  175 lines

  1.                  Installable Device Drivers in C
  2.  
  3.  
  4.      This document is intended to describe a method for using 
  5. Lattice C (small model) to develop Installable Device Drivers for 
  6. MS-DOS.  Additionally, a number of C functions (provided in 
  7. library format) are defined.
  8.  
  9.      Installable Device Drivers are created by first writing the 
  10. functions to be supported, then linking these functions with the 
  11. Driver Header.  A prototype header file is provided in the file 
  12. HDR.ASM.  Note that two data items (the Attribute and Name/unit 
  13. fields) must be filled in with information specific to your 
  14. driver before this file will assemble properly.
  15.  
  16.      The driver header file assumes the existence of the 
  17. following functions (stubs are provided in the DRIVER.LIB library 
  18. file), which perform the various operations described in the 
  19. Installable Device Drivers chapter of the DOS Reference Manual:
  20.  
  21.           Init()
  22.           MediaCheck()
  23.           BuildBPB()
  24.           IoCtlIn()
  25.           Input()
  26.           ndInput()
  27.           InputStatus()
  28.           InputFlush()
  29.           Output()
  30.           OutVerify()
  31.           OutStatus()
  32.           OutFlush()
  33.           IoCtlOut()
  34.           DevOpen()
  35.           DevClose()
  36.           RemMedia()
  37.  
  38.      A sample character device driver is included in this 
  39. package, which allows for a device named "MON".  Outputting to 
  40. this device will cause characters to appear on the IBMPC 
  41. monochrome screen.  Study of the file MONO.C should reveal the 
  42. details of this implementation.
  43.  
  44.      Questions or comments on this package may be directed to:
  45.  
  46.                           Frank Whaley
  47.                        7211 Camino Colegio
  48.                      Rohnert Park, CA  94928
  49.  
  50.      Through the balance of this document, the pseudo-type "Addr" 
  51. is used to describe a long integer value (32-bits) which is used 
  52. to contain a memory address.  Note that the Segment:Offset 
  53. addressing method used in the 8086 family of processors causes 
  54. this data type to be incompatible with true long integers.  The 
  55. following definition is assumed:
  56.  
  57.                       typedef   long Addr;
  58.  
  59.  
  60. Addr EndAddr();
  61.  
  62.      EndAddr() returns the driver's ending address, as required 
  63.      by the Init function call.
  64.  
  65.  
  66. Addr Dword(ptr)
  67.          char    *ptr;
  68.  
  69.      Dword() converts a 16-bit pointer (into the driver's data 
  70.      segment) to a 32-bit pointer.
  71.  
  72.  
  73. int CopyB(from, to, len)
  74.     Addr    from,
  75.         to;
  76.     int    len;
  77.  
  78.      CopyB() copies a section of memory "len" bytes in length 
  79.      from the area whose address is "from" to the area whose 
  80.      address is "to".  Note that this code assumes that the 
  81.      memory sections do not overlap and that a forward copy is 
  82.      correct.  This function returns the number of bytes copied.
  83.  
  84.  
  85. int CopyW(from, to, len)
  86.     Addr    from,
  87.         to;
  88.     int    len;
  89.  
  90.      CopyW() copies a section of memory "len" words in length 
  91.      from the area whose address is "from" to the area whose 
  92.      address is "to".  Note that this code assumes that the 
  93.      memory sections do not overlap and that a forward copy is 
  94.      correct.  This function returns the number of words copied.
  95.  
  96. char InB(port)
  97.     int    port;
  98.  
  99.      InB() inputs and returns a byte from the hardware port 
  100.      described by "port".
  101.  
  102.  
  103. int InW(port)
  104.     int    port;
  105.  
  106.      InW() inputs and returns a word from the hardware port 
  107.      described by "port".
  108.  
  109.  
  110. char OutB(byte, port)
  111.     char    byte;
  112.     int    port;
  113.  
  114.      OutB() outputs the byte "byte" to the hardware port 
  115.      described by "port".  This function returns the output byte.
  116.  
  117.  
  118. char OutW(word, port)
  119.     int    word,
  120.         port;
  121.  
  122.      OutW() outputs the word "word" to the hardware port 
  123.      described by "port".  This function returns the output word.
  124.  
  125.  
  126. char PeekB(addr)
  127.     Addr    addr;
  128.  
  129.      PeekB() returns the byte value found at the absolute address 
  130.      given by "addr".
  131.  
  132.  
  133. int PeekW(addr)
  134.     Addr    addr;
  135.  
  136.      PeekW() returns the word value found at the absolute address 
  137.      given by "addr".
  138.  
  139. char PokeB(val, addr)
  140.     char    val;
  141.     Addr    addr;
  142.  
  143.      PokeB() stores the value "val" into the absolute byte 
  144.      address given by "addr".  This function returns "val".
  145.  
  146.  
  147. int PokeB(val, addr)
  148.     int    val;
  149.     Addr    addr;
  150.  
  151.      PokeB() stores the value "val" into the absolute word 
  152.      address given by "addr".  This function returns "val".
  153.  
  154.  
  155. int SetB(start, len, byte)
  156.     Addr    start;
  157.     int    len;
  158.     char    byte;
  159.  
  160.      SetB() initializes a section of memory "len" bytes in 
  161.      length, beginning with the address given by "start", to the 
  162.      value "byte".  This function returns the number of bytes 
  163.      set.
  164.  
  165.  
  166. int SetW(start, len, word)
  167.     Addr    start;
  168.     int    len,
  169.              word;
  170.  
  171.      SetW() initializes a section of memory "len" words in 
  172.      length, beginning with the address given by "start", to the 
  173.      value "word".  This function returns the number of words 
  174.      set.
  175.